package logic

import (
	"context"
	"wechat/models/mysql"

	"wechat/wechatrpc/internal/svc"
	"wechat/wechatrpc/wechatrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowLogic {
	return &ShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 登录
func (l *ShowLogic) Show(in *wechatrpc.ShowRequest) (*wechatrpc.ShowResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.Wechat
	mysql.DB.Where("id=?", in.Id).Find(&user)
	return &wechatrpc.ShowResponse{
		Id:      int64(user.ID),
		Name:    user.Name,
		Sex:     user.Sex,
		Age:     int64(user.Age),
		Address: user.Address,
	}, nil
}
